home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
edit
/
me_cd25.zip
/
DOC.ZIP
/
ME2MUTT.DOC
< prev
next >
Wrap
Text File
|
1992-11-09
|
59KB
|
1,190 lines
!!!Concepts chapter:
talk about garbage collection: what when
talk general about bags, marks, buffers
talk about current buffer, current window ain't the same
========================================================================
== The ME Mutt Connection Craig Durland 9/89 10/91 11/91 ==
========================================================================
This document describes the link between the Mutt2 programming
language (see MUTT2.DOC) and the Mutt Editor II (see ME2.DOC).
Copyright 1991 Craig Durland
Distributed under the terms of the GNU General Public License.
Distributed "as is", without warranties of any kind, but comments,
suggestions and bug reports are welcome.
========================================================================
== The ME2 Mutt functions ==
========================================================================
(append-to-bag bag-id TEXT <text>)
(append-to-bag bag-id REGION [mark1 mark2])
(append-to-bag bag-id CHARACTERS <number>)
(append-to-bag bag-id RECTANGLE [mark1 mark2])
where TEXT = 0, CHARACTERS = 1, REGION = 2 and RECTANGLE = 3.
TEXT : [NUMBER 0 STRING : VOID]
REGION : [NUMBER 1 [NUMBER [NUMBER]] : VOID]
CHARACTERS : [NUMBER 2 NUMBER : VOID]
RECTANGLE : [NUMBER 3 [NUMBER [NUMBER]] : VOID]
These functions append text to a bag.
TEXT : Appends a string to the bag.
REGION : Appends the text contained in a region.
CHARACTERS : Appends n characters, starting from the dot.
RECTANGLE : Copies the region-rectangle. This clears the bag first.
Note that appending anything to a bag with a rectangle in it
(unless it is another rectangle) is a no-op until you clear the
bag.
For example:
If the region contains "This is a test" then
(clear-bag 0)
(append-to-bag 0 REGION) (append-to-bag 0 TEXT " foo bar")
will set the cut buffer to "This is a test foo bar".
See also: create-bag, clear-bag, insert-register, bag-stats,
bag-to-string.
(arg-flag) [zip : BOOLEAN]
Check to see if somebody set the arg-prefix before calling this
routine (via (universal-argument) or (arg-prefix n)).
See also: arg-prefix.
(arg-prefix [arg]) [[NUMBER] : NUMBER]
Get or set the universal-argument.
With an arg, its the same as ^U before a function.
Notes:
The arg-flag is set to TRUE.
This really sets two prefixes: one for ME commands and one for
Mutt programs. ME commands and exe-key use and reset the prefix
to 1. Programs can only read the prefix and so it will stay the
same for all children of a program unless it is changed by
(arg-prefix n). If it is changed, all the children AND parents
will see the new value. It is a good idea to make a copy of the
value upon entry to a program if it is possible that a child
might change it.
If prefix is not set, it is always 1 (and the arg-flag is FALSE)
when a program or ME command is run from the keyboard.
Note that there is a difference between (arg-prefix 1) and the default.
Setting arg-prefix sets arg-flag. There are commands that just look
at arg-flag and do different things if it is set.
For example, to make META-n start the (universal-argument) count at n,
use the following (where n is 1,2,3,4,5,6,7,8 or 9):
(defun
META-arg { (arg-prefix (- (key-pressed) 0x230))(universal-argument) }
MAIN
{
(int j)
(for (j 1)(< j 10)(+= j 1)
(bind-to-key (concat "META-arg")(concat "M-" j)))
}
)
See also: (arg-flag), (universal-argument) in ME2.DOC.
(argc) [zip : NUMBER]
The number of parameters on the command line when ME was invoked +1.
eg "ME2 foo bar" has argc == 3.
Use argv to look at the parameters.
(argv) [NUMBER : STRING]
The ME command line parameters. There are argc of them, numbering
0...argc-1. (argv 0) is the name of the program (ME) (unless you are
running on MS-DOS 2.x where it is ""), (argv 1) is the first file name
(which is loaded by me2.mut), (argv 2) is the next file name, etc.
See nextfile.mut for an example.
(attached-buffer window-id | buffer-name) [NUMBER|STRING : NUMBER]
If given a number, attached-buffer returns the buffer id that is
attached to window n. n == -1 means use the current window.
If given a name, attached-buffer returns the id of the buffer that is
named name. Returns -2 if the buffer does not exist.
For example:
if the cursor is in third window (window #2) which is displaying
buffer "foobar" and foobar has an id of 123 then:
(attached-buffer -1) and (attached-buffer 2) both return 123.
(attached-buffer "foobar") returns 123.
(attached-buffer "FOOBAR") returns -2.
See also: buffers, windows.
(bag-stats bag-id pointer-to-data) [NUMBER BLOB : VOID]
Get stats on a bag. pointer-to-data is a pointer the the data area
that the stats are put into:
(byte type) (small-int width height) (int size) ;; struct BagInfo
type: 0 means text and 1 is rectangle.
width, height: If the register is a rectangle.
size: Number of bytes in the register.
For example:
(defun get-bag-stats
{
(byte type)(small-int width height)(int size) ;; struct BagInfo
(int n)
(n (convert-to 3 (ask "bag id: ")))
(bag-stats n (loc type))
(msg "bag[" n "]: " (if (== type 0) "Text." "Rectangle.")
" Width:" width " Height:" height " Size:" size
)
})
Note:
If the bag is not a rectangle, the width and height are garbage.
See also: append-to-bag, clear-bag, insert-bag.
(bag-to-file bag-id file-name) [NUMBER STRING : BOOLEAN]
Copy the contents of a bag to a file. If the file already exists, it
is overwritten.
If bag-id is bad, the program aborts.
If some kind of error occurs (can't open file-name or can't write all
of bag), FALSE is returned so you can clean up if necessary.
See also: file-to-bag, bag-to-string
(bag-to-string bag-id) [NUMBER : STRING]
Convert bag contents to a string.
If the bag contains a rectangle, the string will be each line of the
rectangle, one after the other.
Note:
The string sticks around until the bag is changed (clear-bag,
append-to-bag, etc). At that point, the string is garbage and can
cause unknown behavior if used. Use the string or save it - don't
expect it to hang around.
See also: append-to-bag
(bit-and x y [z ...]) [NUMBER NUMBER [NUMBER ...] : NUMBER]
Binary and 2 or more numbers.
See also bit-or, bit-xor.
(bit-or x y [z ...]) [NUMBER NUMBER [NUMBER ...] : NUMBER]
Binary or 2 or more numbers.
See also bit-and, bit-xor.
(bit-xor x y [z ...]) [NUMBER NUMBER [NUMBER ...] : NUMBER]
Binary xor 2 or more numbers.
See also bit-and, bit-or.
(buffer-flags buffer-id [flags]) [NUMBER [NUMBER] : NUMBER]
Get or set the buffer flags. There are 32 flags.
Bit Flag Notes
--- ---- -----
0x0001 Modified 1 if the buffer has been modified since last save.
0x0002 NoCare 1 if don't care about buffer contents.
0x0004 Hidden 1 if buffer is hidden from user.
0x0008 Undo 1 if undo is turned on for the buffer.
0x0010 Mode Tickle bit: force (modeline-hook) to be called.
0x0020 Immortal Not a temporary buffer.
0x0040 Interactive A buffer for humans.
The lower eight bits are reserved for ME2's use, you can use the
other 24. Note - you might want to leave a few bits at the bottom
unused in case I need some more in the future.
Notes:
The Modified flag is set whenever the buffer changes. When it
changes, (modeline-hook) is called.
The NoCare flag is used whenever ME wants exit or change a buffer -
it is set, ME will not ask before changes are made.
A buffer with the Hidden flag set is invisible to the user -
(next-buffer) skips it, the help and command completion routines
ignore it.
If you want a buffer to have u